#ifndef ___MAP_H
#define ___MAP_H

#include <stdint.h>
#include <stdarg.h>
#include <stddef.h>
#include <stdbool.h>

#include "vglobal.h"

#if defined(__cplusplus)
extern "C" {
#endif

typedef struct
{
    bool (*make_pair)(char **key,size_t *key_len,void **value,size_t *val_len);
    int (*free_pair)(char *key,void *value);
    int (*compare_key)(const char *key1,const char *key2);
}vMapOps;

V_DECLEAR_HANDLE(vMap);
V_DECLEAR_HANDLE(vMapIterator);

//参数不能为空
vMap vMapNew(vMapOps *ops);
void vMapDelete(vMap map);

size_t vMapSize(const vMap map);
bool vMapEmpty(const vMap map);

void *vMapFind(const vMap map, char *key);

int vMapInsert(vMap map, char *key, void *value);
int vMapRemove(vMap map, char *key);
int vMapClear(vMap map);

vMapIterator vMapBegin(vMap map);
vMapIterator vMapEnd(vMap map);
void vMapNext(vMap map);

#if defined(__cplusplus)
}
#endif


#endif // ___MAP_H
